import { stringify } from 'qs';
import request from '../utils/request';

// export const remote = `http://47.75.39.150:47400`
// export const remote = `http://127.0.0.1:9999`
export const remote = ``

// =============  REAL API ============== //
export async function queryRule(params) {
  return request(remote+`/api/task/list?${stringify(params)}`);
}
export async function queryRunning() {
  return request(remote+`/api/task/running`);
}

export async function taskDo(params) {
  return request(remote+`/api/task/query?${stringify(params)}`);
}

export async function removeRule(params) {
  return request(remote+'/api/task/delete', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

export async function addRule(params) {
  return request(remote+'/api/task/add', {
    method: 'POST',
    body: {
      ...params,
    },
  });
}

export async function queryBasicProfile(params) {
  return request(remote+`/api/work/result?${stringify(params)}`);
}

export async function queryMachineList() {
  return request(remote+`/api/task/machine_list`);
}

export async function queryAdvancedProfile(params) {
  return request(remote+`/api/work/list?${stringify(params)}`);
}

export async function queryTask(params) {
  return request(remote+`/api/task/get?${stringify(params)}`);
}


// =============  MOCK API ============== //
export async function queryProjectNotice() {
  return request('/api/project/notice');
}

export async function queryActivities() {
  return request('/api/activities');
}

export async function fakeSubmitForm(params) {
  return request('/api/forms', {
    method: 'POST',
    body: params,
  });
}

export async function fakeChartData() {
  return request('/api/fake_chart_data');
}

export async function queryTags() {
  return request('/api/tags');
}

export async function queryFakeList(params) {
  return request(`/api/fake_list?${stringify(params)}`);
}

export async function fakeAccountLogin(params) {
  return request('/api/login/account', {
    method: 'POST',
    body: params,
  });
}

export async function fakeRegister(params) {
  return request('/api/register', {
    method: 'POST',
    body: params,
  });
}

export async function queryNotices() {
  return request('/api/notices');
}
